package com.watson.nettydemo.demo04;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

/**
 * // todo
 *
 * @author: llun
 * @date: 2022/3/11 14:54
 * @version: 1.0
 */
public class SocketServerHandler extends SimpleChannelInboundHandler<String> {
    private int n;
    @Override
    protected void channelRead0(ChannelHandlerContext ctx, String msg) throws Exception {
        n++;
        System.out.println("第{{{{{{{{{"+n+"}}}}}}}}"+ctx.channel().remoteAddress() + "===" + msg);
    }

    @Override
    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
        ctx.close();
    }
}
